﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Management;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CPUtep
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            Double CPUtprt = 0;
            System.Management.ManagementObjectSearcher mos = new System.Management.ManagementObjectSearcher(@"root\WMI", "Select * From MSAcpi_ThermalZoneTemperature");

            try
            {
                foreach (ManagementObject mo in mos.Get())
                {
                    CPUtprt = Convert.ToDouble(Convert.ToDouble(mo.GetPropertyValue("CurrentTemperature").ToString()) - 2732) / 10;
                    textBox1.Text = "CPU 溫度 : " + CPUtprt.ToString();
                   
                }
            }
            catch
            {              
                textBox1.Text = "系统不支持cpu温度查询！";
            }
        }
    }
}
